//反射
//反射值
//反射类型

package main

import (
	"fmt"
	"reflect"
)

type ControllerInterface interface {
	Init(action string, method string)
}

type Controller struct {
	Action string
	Method string
	Tag    string `json:"tag"`
}

func (c *Controller) Init(action string, method string) {
	c.Action = action
	c.Method = method
}

func main() {
	runController := &Controller{Action: "Run1", Method: "GET"}

	var i ControllerInterface
	i = runController

	v := reflect.ValueOf(i)
	fmt.Println("value:", v)

	t := reflect.TypeOf(i)
	fmt.Println("type:", t)

	controllerValue := v.Elem()
	fmt.Println("value is :", controllerValue)

	fmt.Println("action is ", controllerValue.Field(0).String())

	controllerType := t.Elem()
	fmt.Println("tag is ", controllerType.Field(2).Tag) //tag标签说明
}
